package com.songlanyun.modules.withdraw.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.songlanyun.common.enums.WithdrawConstant;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.modules.shop.model.vo.GetShopWithdrawVO;
import com.songlanyun.modules.shop.model.vo.ShopWithdrawVO;
import com.songlanyun.modules.withdraw.entity.Withdraw;
import com.songlanyun.modules.withdraw.model.dto.CommissionToBalanceDTO;
import com.songlanyun.modules.withdraw.model.dto.ShopWithdrawDTO;
import com.songlanyun.modules.withdraw.model.dto.UserWithdrawDTO;
import com.songlanyun.modules.withdraw.model.dto.WithdrawDTO;
import com.songlanyun.modules.withdraw.model.vo.AccountWalletVO;
import com.songlanyun.pay.common.api.ApiResult;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 提现列表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-20 17:47:55
 */
public interface WithdrawService extends IService<Withdraw> {

    PageUtils queryPage(Map<String, Object> params);

    List<Withdraw> exportList(Map<String, Object> params);

    PageUtils memberPage(Map<String, Object> params);

    List<Withdraw> memberList(Long userId);

    /**
     * 初始化创建
     *
     * @param withdrawType        提现类型
     * @param paymentTerm         收款方式
     * @param identityId          身份id
     * @return
     */
    Withdraw init(WithdrawConstant.WithdrawType withdrawType, WithdrawConstant.UserType userType, Integer paymentTerm, Long identityId);

    /**
     * 会员申请分佣提现
     *
     * @param dto
     * @param userId
     */
    void memberWithdraw(UserWithdrawDTO dto, Long userId);

    /**
     * 商家所得提现
     *
     * @param dto
     * @param shopId
     */
    void shopWithdraw(ShopWithdrawDTO dto, Long shopId);

    Withdraw getById(Long id, boolean isThrow);

    void verifyUserWithdrawUp(Long userId, BigDecimal money);

    void verifyUserWithdrawUpForCheck(Long userId, BigDecimal money);

    void verifyShopWithdrawUp(Long shopId, BigDecimal money);

    void verifyShopWithdrawUpForCheck(Long shopId, BigDecimal money);

    void withdrawCheck(WithdrawDTO dto);

    void remit(WithdrawDTO dto);

    AccountWalletVO getWalletInfo(Long userId);

    ShopWithdrawVO statistics(Long shopId);

    void commissionToBalance(Long userId, CommissionToBalanceDTO dto);

    Integer count(Long userId);

    /**
     * 提现
     *
     * @param amount       金额
     * @param identity     唯一标识
     * @param outBizNo     订单号
     * @param withdrawType 提现类型
     * @return
     */
    ApiResult withdraw(BigDecimal amount, String identity, String outBizNo, WithdrawConstant.WithdrawThirdType withdrawType);

    GetShopWithdrawVO getShopWithdraw(ShopWithdrawDTO dto, Long shopId);
}

